home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 281 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: tko.dec.com!diamond
  2. From: diamond@tko.dec.com (Norman Diamond)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Are macros expanded within unused macro arguments?
  5. Date: 2 Feb 1996 05:52:57 GMT
  6. Organization: Digital Equipment Corporation Japan , Tokyo
  7. Message-ID: <4es8rp$98n@usenet.pa.dec.com>
  8. References: <DM3MC3.Atv@scr.siemens.com> <TANMOY.96Feb1102025@qcd.lanl.gov>
  9. Reply-To: diamond@jrdv04.enet.dec-j.co.jp (Norman Diamond)
  10. NNTP-Posting-Host: jit533.tko.dec.com
  11.  
  12. In article <TANMOY.96Feb1102025@qcd.lanl.gov>, tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) writes:
  13. >In article <DM3MC3.Atv@scr.siemens.com> mlg@scr.siemens.com (Michael
  14. >Greenberg) writes: 
  15. >>Is the following program legal?
  16. >>#define foo(unused)
  17. >>#define bar(x,y)
  18. >>foo(bar(1))
  19.  
  20. >I read it as being legal.
  21.  
  22. Mr. Bhattacharya, I am shocked.
  23.  
  24. >>Excerpt from "6.8.3.1 Argument substitution"
  25. >>  After the arguments for the invocation of a function-like macro have
  26. >>  been identified, argument substitution takes place. A parameter in the
  27. >>  replacment list, ..., is replaced by the corresponding argument after
  28. >>  all macros contained therein have been expanded. Before being
  29. >>  substituted, each argument's preprocessing tokens are completely macro
  30. >>  replaced ... .
  31.  
  32. >You gave the reason :-) The quoted text seems to imply the following order:
  33. >  1) Identify parameters
  34. [...]
  35.  
  36. I think there's a preceding order as well:
  37.    0) constraints checked, including ANSI Classic section 3.8.3, page 90
  38.       lines 14 to 15:  "The number of arguments in an invocation of a
  39.       function-like macro shall agree with the number of parameters in
  40.       the macro definition, and [...]"
  41.  
  42. >There is a different problem in the quoted text though: it says that
  43. >before substitution, all macros contained in the parameter are
  44. >supposed to be expanded. I do not think that is what is meant though:
  45. >function like macros not followed by ( cannot be expanded according to
  46. >the last sentence: and I guess this is what was meant anyway.
  47.  
  48. I agree; this needs a DR.
  49. --
  50.  <<  If this were the company's opinion, I would not be allowed to post it.  >>
  51. "I paid money for this car, I pay taxes for vehicle registration and a driver's
  52. license, so I can drive in any lane I want, and no innocent victim gets to call
  53. the cops just 'cause the lane's not goin' the same direction as me" - J Spammer
  54.